#!/usr/bin/expect

set timeout -1

set version [lindex $argv 0]
if {$version == ""} {
    set version "18.1"
}

spawn /root/quartus/QuartusSetup-18.1.1.646-linux.run

expect "Press \\\[Enter\\\] to continue:" { send "\r" }
expect "Press \\\[Enter\\\] to continue:" { send "\r" }

puts "----------------------------------"

set count 45;
while {$count > 0 } {
    expect "Press \\\[Enter\\\] to continue:" { send "\r" }
    puts "\n\ncount : $count\n\n";
    set count [expr $count-1];
}

expect "Do you accept this license? \\\[y/n\\\]" { send "y\r" }
expect "Please choose an option \\\[1\\\]" { send "1\r" }
expect "Specify installation to update \\\[\\\]:" { send "/opt/intelFPGA_lite/$version\r" }
expect "Allow patches to be uninstalled \\\[Y/n\\\]:" { send "n\r" }
expect eof
